home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10669 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: lyra.csx.cam.ac.uk!mae20
  2. From: mae20@cus.cam.ac.uk (M.A. Elliott)
  3. Newsgroups: comp.lang.c
  4. Subject: Capturing useful return values from the parallel port
  5. Date: 19 Mar 1996 09:30:16 GMT
  6. Organization: University of Cambridge, England
  7. Message-ID: <4ilur8$hgi@lyra.csx.cam.ac.uk>
  8. NNTP-Posting-Host: ursa.cus.cam.ac.uk
  9.  
  10. I am building a small routine which is designed to return values 1-4 from a four
  11. button resposne box plugged into the parallel port. The buttons normally return
  12. bits 0 through 3 but I am having problems converting these, elegantly, into the 
  13. required values. 
  14.  
  15. I have been using a routine which returns the product of an XOR bit
  16. transformation. This is fine for two buttons, but obviously not for four.
  17.  
  18. The routine that does this looks like this:
  19.  
  20. @define PORTID  0x379
  21.  
  22. unsigned pressedKey(void)
  23.                     {
  24.  
  25.                        return ((inportb(PORTID) >> 6) ^1);
  26.  
  27.              }  
  28.  
  29.  
  30. If you are able to help me with this I would appreciate contact through either my
  31. Cambridge email or London email addresses. The London one is
  32.  
  33.  
  34. m.elliott@psyc.bbk.ac.uk
  35.  
  36.  
  37. Many Thanks
  38.  
  39.  
  40. Mark 
  41.